/* c4.c
 *	Simple program to help perform multi-client test using networking to implement lock/cv/mv-related syscalls
 *	
 *	Does syscalls that create, acquire, release, and destroy locks and create, wait, signal, broadcast, and destory CVs, create, set, get, destory MVs
 *  through connection to a server. Will be used with one single-threaded server process and up to 5 single-threaded client processes.
 */
#include "syscall.h"

int main(int argc, char **argv)
{   
	int lockIndex, cvIndex, mvIndex;
	PrintOut("\nClient 4: Try to create duplicate lock,CV, MV, acquire, set MV, wait, release\n", 79); 
	PrintOut("\nClient 2: Create Lock, CV, MV, acquire, set MV, wait, release.\n", 64); 
    lockIndex = CreateLock("BobLock", 7, 1); /*Tries to create lock already created by client 1. 
											 Will get index of original lock back*/
	Acquire(lockIndex);
	cvIndex = CreateCV("BobCV", 5, 1);
	mvIndex = CreateMV("BobMV", 5, 1);
	SetMV(mvIndex, 1); /*first int is index of MV, and second int is value to set it to*/
					   /*Setting it to one so Client 5 knows it's waiting and will wake it up*/
	Wait(cvIndex, lockIndex);
	Release(lockIndex);
	/* Then we're done!*/ 
    Halt(); /*MUST do since using networking (post office has own thread)*/
}
